/**
 * @FileName question13
 * @Description
 * @Author Sword
 * @date 2024-12-24
 **/
public class question13 {
    public static void main(String[] args) {
        //以下歌词节选自 Michael Jackson 的 Beat It 曲目，请从这段歌词中统计出
        //beat 出现的次数。可以组合使用 String 类的相关方法

        String song = "They're out to get you, better leave while you can\n" +
                " Don't wanna be a boy, you wanna be a man\n" +
                " You wanna stay alive, better do what you can\n" +
                " So beat it da just beat it du\n" +
                " You have to show them that you're really not scared\n" +
                " You're playing with your life, this ain't no truth or dare oh\n" +
                " They'll kick you, then they'll beat you, then they'll tell you it's fair\n" +
                " So beat it da, but you wanna be bad\n" +
                " Just beat it beat it, beat it beat it\n" +
                " No one wants to be defeated\n" +
                " Showing how funky and strong is your fight\n" +
                " It doesn't matter who's wrong or right\n" +
                " Just beat it beat it, beat it beat it\n" +
                " No one wants to be defeated\n" +
                " Showing how funky and strong is your fight";

        // 统计 "beat" 出现的次数
        int count = 0;
        String wordToCount = "beat";
        String[] words = song.split("\\W+"); // 按非字母数字字符分割字符串

        for (String word : words) {
            if (word.equalsIgnoreCase(wordToCount)) { // 忽略大小写比较
                count++;
            }
        }

        // 输出结果
        System.out.println("\"" + wordToCount + "\" 出现的次数: " + count);

    }
}
